package plusOne;

public class Solution {
    public int[] plusOne(int[] digits) {
        int t = 1;//表示进位
        int index = digits.length-1;
        while(t!=0&&index>=0){
            int sum = digits[index] + t;
            digits[index] = sum%10;
            t = sum/10;
            index--;
        }
        if(t!=0){
            int[] arr = new int[digits.length+1];
            arr[0] = 1;
            return arr;
        }
        return digits;
    }
}
